---
name: pxapi-copybara
on:
  workflow_dispatch:
  push:
    branches:
    - 'main'
permissions:
  contents: read
jobs:
  run-copybara:
    runs-on: ubuntu-latest
    container:
      image: gcr.io/pixie-oss/pixie-dev-public/copybara:20210420
    steps:
    - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3  # v3.5.0
    - id: create-ssh-key
      env:
        COPYBARA_SSH_KEY: ${{ secrets.COPYBARA_SSH_KEY }}
      run: echo "$COPYBARA_SSH_KEY" > /tmp/sshkey && chmod 600 /tmp/sshkey
    - id: pxapi-copybara
      env:
        COPYBARA_GPG_KEY: ${{ secrets.COPYBARA_GPG_KEY }}
        COPYBARA_GPG_KEY_ID: ${{ secrets.COPYBARA_GPG_KEY_ID }}
      run: >
        GIT_SSH_COMMAND='ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i /tmp/sshkey'
        ./ci/run_copybara.sh tools/copybara/pxapi_go/copy.bara.sky
